package com.jazz.thread;

public class Interruption {
	public static void main(String[] args) {
		new Thread("interrupt test") {
			public void run() {
				for (;;) {
					// doXXX();
					if (Thread.interrupted()) {
						break;
					}
				}
			}
		}.start();
	}
}

class MyThread1 extends Thread {
	private volatile boolean isStop = false;

	public void run() {
		while (isStop) {
			// code
		}
	}

	public void shutDown() {
		isStop = true;
	}
}

class MyThread2 extends Thread {
	public void run() {
		while (!isInterrupted()) {
			// code
		}
	}

	public void shutDown() {
		interrupt();
	}
}
